

<template>
	<view class="s-back subscribe">
        <view class="flex">
			<view class="text1" style="visibility: hidden;">
				<uni-icons type="back" size="25" @click="goBack" color="#fff"></uni-icons>
			
			</view>
			<view class="flex1">登录</view>
			<view class="right" style="color:transparent">恢复订阅</view>		
        </view>

		<view class="inp1" style="margin-top:120rpx">

			<input class="inpt" placeholder="用户名/手机号/邮箱" 
							confirm-type="send" style="font-size: 30rpx;" 
							cursor-spacing="40"
							  
							ref="inputRef" v-model="username" :adjust-position="false"/> 
							
						</view>

						<view class="inp1">

						<input class="inpt" placeholder="请输入密码" 
							confirm-type="send" style="font-size: 30rpx;" 
							cursor-spacing="40"
							  
							ref="inputRef" v-model="password" :adjust-position="false"/> 
		
	

						</view>
		<view class="btn" @click="login">登录</view>
		
		<view style="display: flex;justify-content: space-between;align-items: center;">
			<view @click="jumpRegister" class="left">
			注册
		</view>
		<!-- <view @click="jumpWechat" class="left">
			微信登录
		</view> -->
		</view>
		
	
	</view>
</template>

<script>
	export default {
		name:"subscribe",
    components:{},
		data() {
			return {
				username:'',
				password:''
				
            }
		},
		onLoad() {
				
		},
		mounted() {
			
		},
		destroyed() {
			
		},
		
		computed:{
			
		},
		methods: {
			goBack(){
				uni.navigateBack({
					 delta: 1
				});
			},
			jumpWechat(){
				uni.navigateTo({
					url:'/pages/wechatLogin/wechatLogin'
				})
			},
			jumpRegister(){
				uni.navigateTo({
					url:'/pages/register/register'
				})
			},
			async login(){
				const r = await this.$u.api.userLogin({
					mobile:this.username,
					password:this.password
				})
				if(r){
					this.$u.toast('登录成功');
					this.getPageData()
                  	this.getRemindData()
					uni.setStorageSync('token',r.data.token)
					await this.getUserId()
					uni.$emit('updateDataMy')
					setTimeout(()=>{
					
						uni.switchTab({
							url:'/pages/index/index'
						})
					},1000)
				}
			},
			async getPageData(){
				const r = await this.$u.api.configTitle()
				if(r){
					uni.setStorageSync('pageTitle',r.data.title)
				}
			},
			async getRemindData(){
	// 			"zdz_remind": "查出",
    // "welcome": "欢迎"
				const r = await this.$u.api.configRemind()
				if(r){
					uni.setStorageSync('welcome',r.data.welcome)
				}
			},
			async getUserId(){
				let r = await this.$u.api.userInfo()
				if (r) {
					localStorage.setItem('userId',r.data.id)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
.subscribe{
	.flex{
		padding:24rpx;
		display: flex;
		color: #fff;
	}
	.text1{
		width: 130rpx;
	}
	.flex1{
		display: flex;
		justify-content: center;
		flex: 1;
		font-size: 36rpx;
	}
	.right{
		color: #828694;
		font-size: 32rpx;
	}
	.inp1{
			
			padding: 16rpx 20rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			flex-direction: row;
			margin:40rpx;
			border-radius: 60rpx;
			border: 1px solid #78A4A1;

			.inpt{
				margin-left: 20rpx;
				color: #fff;
			}
		}
		.btn{

			border-radius: 50rpx;
			background-image: linear-gradient(to top, #7CD887,#75CCD1);
			padding:26rpx 40rpx;
			color:#000;
			font-size: 30rpx;
			font-weight: 500;
			text-align: center;
			margin:40rpx;
		}
		.left{
			margin:40rpx 60rpx;
			color: #797979;
		}
	
	
}
@media screen and (min-width: 700px) {
	.btn{
		width: 660px;
	}
	
}
</style>
